package com.six.statistical.controller;

import com.six.core.entity.Shop;
import com.six.core.vo.Result;
import com.six.statistical.fegin.ShopFegin;
import com.six.statistical.fegin.UserFegin;
import com.six.statistical.vo.ShopAndUserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * ClassName:ExcelController
 * Description:
 * date:2023/2/28 11:51
 *
 * @since JDK 1.8
 */
@RestController
@RequestMapping("statistical/statistical")
public class ExcelController {

    @Autowired
    private ShopFegin shopFegin;
    @Autowired
    private UserFegin userFegin;
    @Autowired
    private ShopAndUserVo shopAndUserVo;
    @PostMapping("findByShopAndUserNum")
    public Result findByShopNum(){
        Integer byNum = shopFegin.getByNum();
        Integer byUserNum = userFegin.findByUserNum();

        List<ShopAndUserVo> shopAndUserVos = new ArrayList<>();
        ShopAndUserVo shopAndUserVo = new ShopAndUserVo();
        shopAndUserVo.setName("商家");
        shopAndUserVo.setValue(byNum);

        ShopAndUserVo shopAndUserVo1 = new ShopAndUserVo();
        shopAndUserVo1.setName("用户");
        shopAndUserVo1.setValue(byUserNum);

        shopAndUserVos.add(shopAndUserVo);
        shopAndUserVos.add(shopAndUserVo1);

        return new Result(2000,"查询店铺和用户比例成功",shopAndUserVos);
    }
    @PostMapping("findShopAndPrice")
    public Result findShopAndPrice(){
        List<ShopAndUserVo> price = shopFegin.getByShopAndPrice();
        System.out.println(price);
        return new Result(2000,"查询成功",price);
    }
}
